import { Form, Validator } from 'spd-components/form';
import { Input, Form as AntdForm, Select } from 'antd';
// import { IEnterpriseStruct, addDepartment } from '../rquests';
import { message } from 'antd';
import { RoleRequest, RoleStruct } from 'spd-request/role';
import { useState, useEffect } from 'react';
import { RoleSelectTree, DepartmentSelectTree } from 'spd-project-component/form'

export function UserForm() {

    let [formInstance] = AntdForm.useForm();
    function onSubmit() {

    }
    function onCancel() {
        
    }
    return (
        <Form.Ctx.Provider value={{onSubmit: onSubmit, formInstance: formInstance, onCancel: onCancel}}>
            <Form.Modal title="添加人员">
                <Form.Container>
                    <Form.Item 
                        labelName="姓名" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <Input placeholder="请输入姓名"></Input>
                    </Form.Item>
                    <Form.Item 
                        labelName="角色" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <RoleSelectTree />
                    </Form.Item>
                    <Form.Item 
                        labelName="手机" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <Input placeholder="请输入手机号"></Input>
                    </Form.Item>
                    <Form.Item 
                        labelName="邮箱" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <Input placeholder="请输入邮箱"></Input>
                    </Form.Item>
                    <Form.Item 
                        labelName="部门" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <DepartmentSelectTree placeholder="请选择部门"/>
                    </Form.Item>
                    <Form.Item 
                        labelName="密码" 
                        name="displayName"
                        rule={[
                            Validator.MaxLength('名称过长', 20),
                            Validator.MinLength('最少不小于2个字', 4)
                        ]}
                    >
                        <Input placeholder="请输入密码，不输入时默认为123456"></Input>
                    </Form.Item>
                </Form.Container>
            </Form.Modal>
        </Form.Ctx.Provider>
    );
}